package com.hongfan.oauth.controller;

import com.hongfan.common.model.ResultMsg;
import com.hongfan.oauth.dto.Oauth2TokenDto;
import com.hongfan.oauth.service.AuthService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;


/**
 * @author zcs
 * @since 2023/10/16
 */
@RestController
@RequestMapping("/oauth")
public class AuthController {

    @Resource
    AuthService authService;

    /**
     * 获取凭证Token
     */
    @PostMapping("/token")
    public ResultMsg<Oauth2TokenDto> postAccessToken(@RequestParam String username, @RequestParam String password) {
        Oauth2TokenDto tokenDto = authService.postAccessToken(username,password);
        if (tokenDto != null) {
            return ResultMsg.success(tokenDto);
        }
        return ResultMsg.error("获取认证信息失败");
    }

}
